package com.agileboot.domain.airport.inspectionUser.db;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 检查人员关联表 Mapper 接口
 * </p>
 */
public interface SirInspectionUserMapper extends BaseMapper<SirInspectionUserEntity> {
    /**
     * 根据检查计划 ID 获取用户 ID 列表
     * @param inspectionId 检查计划 ID
     * @return 用户 ID 列表
     */
    @Select("SELECT user_id FROM sir_inspection_user WHERE inspection_id = #{inspectionId}")
    List<Long> selectUserIdByInspectionId(Long inspectionId);

    /**
     * 根据多个检查流程 ID 物理删除对应的检查人员记录
     * @param inspectionIds 检查流程 ID 列表
     * @return 删除的记录数
     */
    @Delete("<script>" +
            "DELETE FROM sir_inspection_user " +
            "WHERE inspection_id IN " +
            "<foreach item='item' index='index' collection='inspectionIds' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    int deleteByInspectionIdsPhysically(@Param("inspectionIds") List<Long> inspectionIds);

}
